package maf;


  import static org.junit.Assert.assertTrue;
  import robocode.control.events.BattleCompletedEvent;
  import robocode.control.events.TurnEndedEvent;
  import robocode.control.snapshot.IRobotSnapshot;
  import robocode.control.testing.RobotTestBed;

  /**
   * Tests that CompetitiveRobot moves to the upper left corner to start it's movement pattern.
   * @author Philip Johnson, modified by Michael Fujimoto
   *
   */

  public class TestCompRobotMovement extends RobotTestBed {
    /** True if the robot visited this corner during the test case. */
    boolean visitedUpperLeft = false;
    /**
     * Specifies that SittingDuck and DaCruzer are to be matched up in this test case.
     * @return The comma-delimited list of robots in this match.
     */
    @Override
    public String getRobotNames() {
      return "sample.SittingDuck,maf.CompetitiveRobot";
    }
    
    /**
     * This test runs for 1 round.
     * @return The number of rounds. 
     */
    @Override
    public int getNumRounds() {
      return 10;
    }
    
    /**
     * After each turn, check to see if we're at a corner.  If so, set the corresponding flag.
     * @param event Info about the current state of the battle.
     */
    @Override 
    public void onTurnEnded(TurnEndedEvent event) {
      IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
      double xPos = robot.getX();
      double yPos = robot.getY();
      //Checks to see if the robot visited the top left corner
      if ((xPos < 40) && (yPos < 40)) {
        visitedUpperLeft = true;
      }
    }
    
    
    /**
     * After the battle, check to see that we've visited the corners. 
     * @param event Details about the completed battle.
     */
    @Override
    public void onBattleCompleted(BattleCompletedEvent event) {
      assertTrue("Check UpperLeft", visitedUpperLeft);
    }
}
